package com.adnaan.backend.mapper;

import com.adnaan.backend.entity.UserCollect;
import com.adnaan.backend.entity.ViewHistory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface UserCollectMapper extends BaseMapper<UserCollect> {
    void deleteCollect(Long userId, Long articleId);

    UserCollect selectByUserIdAndArticleId(Long userId, Long articleId);

    void insertCollect(UserCollect userCollect);

    long collectCount(Long userId);

    List<UserCollect> selectPage(@Param("offset") long offset, @Param("size") long size, @Param("userId") Long userId);

    long viewHistoryCount(@Param("userId") Long userId);

    List<ViewHistory> viewHistoryPage(@Param("offset") long offset, @Param("size") long size, @Param("userId") Long userId);

    Integer getCollectCount(@Param("articleId") Long articleId);

    /**
     * 统计指定时间范围内每天的收藏数
     */
    List<Map<String, Object>> countGroupByDate(LocalDateTime startTime, LocalDateTime endTime);
}
